<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>v-model对可输入组件绑定</title>
    <script src="vue.js"></script>
</head>
<body>
    <div id="app">
        {{inputValue}}
        <custom-input v-model="inputValue"></custom-input>
        <custom-input v-bind:value="inputValue" v-on:input="inputValue = $event">222</custom-input>
    </div>

    <script>
        Vue.component('custom-input', {
            data: function () {
                return {

                }
            },
            methods: {
                
            },
            props: {
                value: 0,
            },
            template: `
                <div>
                    <input v-bind:value="value" v-on:input="$emit('input', $event.target.value)"></input>
                    <slot></slot>
                </div>
            `
        });

        const vm = new Vue({
            el: '#app',
            data: {
                inputValue: 0,
            },
            methods: {

            }
        });
    </script>
</body>
</html>